import 'package:flutter/material.dart';

class ColorsUtils {
  ColorsUtils._();

  static const String colorFfff = '#FFFFFF';

  static const String colorCccc = '#cccccc';

  static const String color0052 = '#0052d9';

  static const String colorF6f6 = '#f6f6f6';

  static const String color9999 = '#999999';

  static const String colorD900 = '#D9001B';

  static const String color4950 = '#495060';

  static const String color1c24 = '#1C2438';

  static const String color3333 = '#333333';

  static const String color669e = '#699ef5';

  static const String color0bb2 = '#0bb27a';

  static const String colorF3f6 = '#f3f6ff';

  static const String colorD7d7 = '#d7d7d7';

  static const String colorF2f2 = '#f2f2f2';

  static const String colorF9f9 = '#f9f9f9';

  static const String colorFf90 = '#FF9032';

  static const String colorE4e4 = '#e4e4e4';

  static const String colorAaaa = '#aaaaaa';

  static const String colorE34d = '#e34d59';

  static const String colorFf6e = '#FF6E53';

  static const String color7979 = '#797979';

  static const String color6666 = '#666666';

  static const String colorE6e6 = '#e6e6e6';

  static const String colorF3f3 = '#f3f3f3';

  static const String color0000 = '#000000';

  static const String colorE9e9 = '#e9e9e9';

  static const String color00b2 = '#00b27a';

  static const String colorF59a = '#F59A23';

  static const String color1677 = '#1677ff';

  static const String colorE2ea = '#e2eaf2';

  static const String colorFf31 = '#ff3141';

  static const String color2ba4 = '#2BA471';

  static const String color005e = '#005EAA';

  static const String colorEb65 = '#EB6565';

  static Color fromRGBO([int r = 255, int g = 255, int b = 255, double opacity = 1.0]) {
    return Color.fromRGBO(r, g, b, opacity);
  }

  static Color rgba([int r = 255, int g = 255, int b = 255, double opacity = 1.0]) {
    return fromRGBO(r, g, b, opacity);
  }

  static Color parseColorFromHexString(String code) {
    Color result = Colors.red;
    int value = 0;
    if (code.contains('#')) {
      try {
        value = int.parse(code.substring(1), radix: 16);
      } catch (e) {
        debugPrint(e.toString());
      }
      switch (code.length) {
        case const (1 + 6):

          ///6位
          result = Color(value + 0xFF000000);
          break;
        case const (1 + 8):

          ///8位
          result = Color(value);
          break;
        default:
          result = Colors.red;
      }
    } else {
      try {
        value = int.parse(code, radix: 16);
      } catch (e) {
        debugPrint(e.toString());
      }
      switch (code.length) {
        case 6:
          result = Color(value + 0xFF000000);
          break;
        case 8:
          result = Color(value);
          break;
        default:
          result = Colors.red;
      }
    }
    return result;
  }

  static Color colorFromHexString(String? s) {
    return parseColorFromHexString(s ?? colorFfff);
  }
}
